<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%bai_rong_validate_log}}".
 *
 * @property string $id
 * @property string $strategy_type
 * @property string $req_name
 * @property string $req_idcard
 * @property string $req_mobile
 * @property string $api_send_post_data
 * @property string $resp_code
 * @property string $resp_swift_number
 * @property string $resp_data_for_api_send
 * @property int $created_at
 * @property string $is_old_from_console
 * @property string $other_data
 * @property int $import_type
 *
 * @property BaiRongValidateForCreditOrder[] $baiRongValidateForCreditOrders
 * @property CreditOrder[] $creditOrders
 */
class BaiRongValidateLog extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%bai_rong_validate_log}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['strategy_type', 'req_name', 'req_idcard', 'req_mobile', 'api_send_post_data', 'resp_code', 'resp_data_for_api_send', 'created_at'], 'required'],
            [['api_send_post_data', 'resp_data_for_api_send', 'other_data'], 'string'],
            [['created_at', 'is_old_from_console', 'import_type'], 'integer'],
            [['strategy_type', 'req_name', 'req_idcard'], 'string', 'max' => 50],
            [['req_mobile'], 'string', 'max' => 11],
            [['resp_code'], 'string', 'max' => 10],
            [['resp_swift_number'], 'string', 'max' => 100],
            [['strategy_type', 'req_name', 'req_idcard', 'req_mobile'], 'unique', 'targetAttribute' => ['strategy_type', 'req_name', 'req_idcard', 'req_mobile']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'strategy_type' => Yii::t('app', 'Strategy Type'),
            'req_name' => Yii::t('app', 'Req Name'),
            'req_idcard' => Yii::t('app', 'Req Idcard'),
            'req_mobile' => Yii::t('app', 'Req Mobile'),
            'api_send_post_data' => Yii::t('app', 'Api Send Post Data'),
            'resp_code' => Yii::t('app', 'Resp Code'),
            'resp_swift_number' => Yii::t('app', 'Resp Swift Number'),
            'resp_data_for_api_send' => Yii::t('app', 'Resp Data For Api Send'),
            'created_at' => Yii::t('app', 'Created At'),
            'is_old_from_console' => Yii::t('app', 'Is Old From Console'),
            'other_data' => Yii::t('app', 'Other Data'),
            'import_type' => Yii::t('app', 'Import Type'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getBaiRongValidateForCreditOrders()
    {
        return $this->hasMany(BaiRongValidateForCreditOrder::className(), ['bai_rong_validate_log_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCreditOrders()
    {
        return $this->hasMany(CreditOrder::className(), ['id' => 'credit_order_id'])->viaTable('{{%bai_rong_validate_for_credit_order}}', ['bai_rong_validate_log_id' => 'id']);
    }
}
